#include<iostream>
#include<cstring>
#include<string>
using namespace std;
string str;
int ch[26];
bool is_ok()
{
	for (int i = 0; i < 26; i++) {
		if (!ch[i]) {
			return 0;
		}
	}
	return 1;
}
int main()
{
	cin >> str;
	int mi = 100;

	for (int l = 0, r = 0; r < str.size(); r++) {
		ch[str[r] - 'a']++;
		while (is_ok()) {
			ch[str[l]-'a']--;
			mi = min(mi, r - l + 1);
			l++;
		}
	}
	cout << mi << endl;
	return 0;
}